package xj.graph2d.dialog;

import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;

public class OptionDialogPanel 
  extends JPanel {

  public OptionDialogPanel(JFrame owner) { 
    this.owner = owner;
  }

  public OptionDialogPanel(JFrame owner,
			   int style) { 
    this.owner = owner;
    this.style = style;
  }

  public OptionDialogPanel(JFrame owner,
			   String title) {
    this.owner = owner;
    this.title = title;
  }

  public OptionDialogPanel(JFrame owner,
			   int style, 
			   String title) {
    this.owner = owner;
    this.style = style;
    this.title = title;
  }

  public String getTitle() {
    return title;
  }

  public void setTitle(String title) {
    this.title = title; 
  }  

  public int getStyle() {
    return style;
  }

  public void setStyle(int style) {
    this.style = style; 
  }  

  public boolean showOptionDialog() {
    int result = JOptionPane.showOptionDialog(owner, this, title, style, 
					      JOptionPane.PLAIN_MESSAGE, 
					      null, null, null);
    if (result == JOptionPane.OK_OPTION ||
	result == JOptionPane.YES_OPTION) { 
      applyOptions();
      return true;
    }
    return false; 
  }

  public void applyOptions() {} 

  protected JFrame owner;
  
  protected int style = JOptionPane.OK_CANCEL_OPTION;
  
  protected String title = "Dialog";

}
